<?php
header('Content-Type:text/html;charset=utf-8');
date_default_timezone_set('prc');
if (!(empty($_POST)))
{
   $username=isset($_POST["username"]) ? trim($_POST["username"]) :"";
    $password=isset($_POST["password"]) ? trim($_POST["password"]) :"";
    $re=  isset($_POST["re"]) ? $_POST["re"] :"";
    $time=(date('y-m-d　H:i:s'));
    if (($username==="admin") && ($password==="admin"))
    {
        if ($re)
        {
            setcookie("cname",$username,time()+3600*24);
        setcookie("csj",$time,time()+3600*24);
         }
//成功登录,并且你勾选了记住用户名，将这个用户名填到cookie里
        echo "ok";
   }
 else {
       
 {
   echo "<script language='javascript' type='text/javascript'>";
           echo "alert('登录失败！');";
           echo "window.location.href='login.php'";
           echo "</script>"; 
 }
}
}

